ioemu: xenfb shared memory patch
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 3 Mar 2008 13:19:44 +0000 (13:19 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 3 Mar 2008 13:19:44 +0000 (13:19 +0000)
Share the internal xenfb backend buffer with sdl or vnc. All the
needed functions are already in place because have been implemented
for the previous cirrus vga shared memory patch.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/ioemu/hw/xenfb.c
tools/ioemu/vl.h

index f4c69a111c3481bca5724d2570caf790a7f42159..3f22664b164f8a81bbb9f3a3376cd383acb92df0 100644 (file)
@@ -1112,36 +1112,38 @@ static void xenfb_guest_copy(struct xenfb *xenfb, int x, int y, int w, int h)
 {
     int line;
 
-    if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
-        for (line = y ; line < (y+h) ; line++) {
-            memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
-                   xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
-                   w * xenfb->depth / 8);
-        }
-    } else { /* Mismatch requires slow pixel munging */
-        /* 8 bit == r:3 g:3 b:2 */
-        /* 16 bit == r:5 g:6 b:5 */
-        /* 24 bit == r:8 g:8 b:8 */
-        /* 32 bit == r:8 g:8 b:8 (padding:8) */
-        if (xenfb->depth == 8) {
-            if (xenfb->ds->depth == 16) {
-                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
-            }
-        } else if (xenfb->depth == 16) {
-            if (xenfb->ds->depth == 8) {
-                BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
+    if (!xenfb->ds->shared_buf) {
+        if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
+            for (line = y ; line < (y+h) ; line++) {
+                memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
+                        xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
+                        w * xenfb->depth / 8);
             }
-        } else if (xenfb->depth == 24 || xenfb->depth == 32) {
-            if (xenfb->ds->depth == 8) {
-                BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
-            } else if (xenfb->ds->depth == 16) {
-                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
+        } else { /* Mismatch requires slow pixel munging */
+            /* 8 bit == r:3 g:3 b:2 */
+            /* 16 bit == r:5 g:6 b:5 */
+            /* 24 bit == r:8 g:8 b:8 */
+            /* 32 bit == r:8 g:8 b:8 (padding:8) */
+            if (xenfb->depth == 8) {
+                if (xenfb->ds->depth == 16) {
+                    BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
+                }
+            } else if (xenfb->depth == 16) {
+                if (xenfb->ds->depth == 8) {
+                    BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
+                }
+            } else if (xenfb->depth == 24 || xenfb->depth == 32) {
+                if (xenfb->ds->depth == 8) {
+                    BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
+                } else if (xenfb->ds->depth == 16) {
+                    BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
+                }
             }
         }
     }
@@ -1180,7 +1182,10 @@ static int xenfb_register_console(struct xenfb *xenfb) {
                             xenfb_invalidate,
                             xenfb_screen_dump,
                             xenfb);
+       dpy_colourdepth(xenfb->ds, xenfb->depth);
        dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
+       if (xenfb->ds->shared_buf)
+           dpy_setdata(xenfb->ds, xenfb->pixels);
 
        if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
                return -1;
index 66e4ded2d34641cd8392dee7727a8ca2c4429b6b..fcaf70488d26ec17b0fe6f7c60cf486cb24a72bc 100644 (file)
@@ -942,7 +942,7 @@ struct DisplayState {
     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
     void (*dpy_resize)(struct DisplayState *s, int w, int h);
     void (*dpy_colourdepth)(struct DisplayState *s, int depth);
-    void (*dpy_setdata)(DisplayState *ds, void *pixels);
+    void (*dpy_setdata)(DisplayState *s, void *pixels);
     void (*dpy_refresh)(struct DisplayState *s);
     void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
 };
@@ -957,6 +957,17 @@ static inline void dpy_resize(DisplayState *s, int w, int h)
     s->dpy_resize(s, w, h);
 }
 
+static inline void dpy_colourdepth(struct DisplayState *s, int depth)
+{
+    s->dpy_colourdepth(s, depth);
+}
+
+static inline void dpy_setdata(DisplayState *s, void *pixels)
+{
+    s->dpy_setdata(s, pixels);
+}
+
+
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
                  unsigned long vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,